<template>
	<view>
		
		<block v-if="loading">
			<empty :loading="true"></empty>
		</block>
		<block v-else>
			
			<view class="flex whiteBg plr bb">
				<view>
					<range-picker @change="changeDate"></range-picker>
				</view>
				<staffAuth>
					<navigator :url="`/pages/repaire/repaireSave?id=${params.id}`">
						<view class=" ptb10 flex left">
							<text class="pr5 fz16 sIcon-addCircle bold main"></text>
							<view>
								添加记录
							</view>
						</view>
					</navigator>
				</staffAuth>
			</view>
			
			
			<view class="mt10">
				<view class=" whiteBg  mb10 " v-for="( item , index) in page.list" :key="index">
					
					<collapser :title="item.typeStr">
						
						<view>
							{{item.startTime}}
						</view>
						
						<template slot="content">
							<view class="pd pb10">
								
								<view class="flex">
									<view>
										<text class="grey mr5">故障开始时间</text>
									</view>
									<view>
										{{item.startTime}}
									</view>
								</view>
								<view class="flex pt5">
									<view>
										<text class="grey mr5">故障结束时间</text>
									</view>
									<view>
										{{item.endTime}}
									</view>
								</view>
								<view class="flex pt5">
									<view>
										<text class="grey mr5">故障类型</text>
									</view>
									<view>
										{{item.typeStr}}
									</view>
								</view>
								
								<view class="flex pt5">
									<view>
										<text class="grey mr5">重新验收</text>
									</view>
									<view>
										{{item.needCheck ? "需要" : "不需要"}}
									</view>
								</view>
								<view class="flex pt5">
									<view>
										<text class="grey mr5">重新校准</text>
									</view>
									<view>
										{{item.needCalibration ? "需要" : "不需要"}}
									</view>
								</view>
								<view class="flex pt5">
									<view>
										<text class="grey mr5">重新校验</text>
									</view>
									<view>
										{{item.needRecheck ? "需要" : "不需要"}}
									</view>
								</view>
								
								
								
							</view>
							
							<view class="pd ptb10  bt dashed">
								
								<view class="fixAutoNoPd">
									<view class="w90 grey">
										故障情况
									</view>
									<view>
										{{item.remark}}
									</view>
								</view>
								<view class="fixAutoNoPd pt5">
									<view class="w90 grey">
										更换部件情况
									</view>
									<view>
										{{item.repairRemark}}
									</view>
								</view>
								
							</view>
							
							<view class="pd ptb10  bt dashed">
								
								<view class="flex">
									<view>
										<text class="grey mr5">运维公司</text>
									</view>
									<view>
										{{item.name}}
									</view>
								</view>
								
								<view class="flex pt5">
									<view>
										<text class="grey mr5">运维人员</text>
									</view>
									<view>
										{{item.recorder}}
									</view>
								</view>
							</view>
							
						</template>
						
						
					</collapser>
					
				</view>
			</view>

			<empty :loading="false" :list="page.list"></empty>

		</block>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				params : {id:""}, 
				page : {
					list : [] ,
					lastPage : false ,
					pageNumber : 1 ,
					pageSize : 10
				},
				endTime : "" ,
				startTime : "" ,
				loading : true ,
				refresh : false 
			}
		},
		
		onLoad(p) {
			this.params = p ;
		},
		
		onShow() {
			this.page.pageNumber = 1 ;
			this.loadData();
		},
		
		onReachBottom() {
			if (this.page.lastPage) {
				return ;
			}
			this.page.pageNumber ++ ;
			this.loadData();
		},
		
		onPullDownRefresh() {
			if (this.refresh) {
				return ;
			}
			uni.startPullDownRefresh({});
			this.refresh = true ;
			this.page.pageNumber = 1 ;
			this.loadData();
		},
		
		methods: {
			changeDate : function(e){
				this.startTime = e.startDate ;
				this.endTime = e.endDate ;
				this.loadData();
			},
			loadData:function(e){
				var data = {
					startTime : this.startTime ,
					endTime : this.endTime ,
					pageNumber : this.page.pageNumber ,
					pageSize : this.page.pageSize ,
					"stationId" : this.params.id 
				} ;
				this.kit.get("/api/repaire/list",data,res => {
					if (res.page.pageNumber > 1) {
						res.page.list = this.page.list.concat(res.page.list);
					}
					this.page = res.page ;
					this.loading = false ;
					this.refresh = false ;
				});
			},
			
		}
	}
</script>